const characterInfo = uni.getStorageSync('character') || null;
const data = {
	character: characterInfo
}
export function randomCharacterName() {
	const characterNames = ["云天河", "韩菱纱", "柳梦璃", "慕容紫英", "景天", "唐雪见", "龙葵", "徐长卿", "赵灵儿", "李逍遥", "林月如", "酒剑仙", "百里屠苏", "风晴雪", "方兰生", "襄铃", "姜承", "欧阳慧", "夏侯瑾轩", "瑕", "南宫煌", "王蓬絮", "星璇", "温慧", "玄霄", "夙玉", "云天青", "梦貘", "飞蓬", "夕瑶", "重楼", "龙幽", "苏行秋", "闻人羽", "夏夷则", "居十方", "乐无异", "闻人翊歌", "阿阮", "谢衣", "沈夜",
		"华月", "瞳", "悭臾", "紫英", "天青", "玉涵", "雨柔", "南晓", "春风", "剑圣", "琴音"
	]
	const v = uni.$uv.random(0, characterNames.length - 1);
	return characterNames[v];
}
// 角色表
export const characterList = [{
	name: '学生',
	type: 'STUDENT',
	children: [{
		avatar: 'avatar-student-1',
		needVip: false
	}, {
		avatar: 'avatar-student-2',
		needVip: false
	}, {
		avatar: 'avatar-student-3',
		needVip: false
	}, {
		avatar: 'avatar-student-4',
		needVip: false
	}, {
		avatar: 'avatar-student-5',
		needVip: true
	}, {
		avatar: 'avatar-student-6',
		needVip: true
	}]
}, {
	name: '教师',
	type: 'TEACHER',
	children: [{
		avatar: 'avatar-teacher-1',
		needVip: false
	}, {
		avatar: 'avatar-teacher-2',
		needVip: false
	}]
}, {
	name: '机构',
	type: 'INST',
	children: [{
		avatar: 'avatar-inst',
		needVip: false
	}]
}]
/**
 * 检测本地是否有选择的角色
 */
export function checkLocalCharacter() {
	if (!dzcharacter.character || dzcharacter.character?.type === 'TEACHER') {
		uni.redirectTo({
			url: '/pages/character/character'
		})
		throw new Error('还没有角色！');
	}
}
/**
 * 设置角色保存到本地
 * @param {Object} data 角色相关的信息
 */
export function setLocalCharacter(data) {
	if (data) {
		dzcharacter.character = data;
		uni.setStorageSync('character', data);
	}
}
/**
 * 删除角色
 * @param {Object} data 角色相关的信息
 */
export function delLocalCharacter(data) {
	if (data && data.characterId == dzcharacter.character?.characterId) {
		dzcharacter.character = null;
		uni.removeStorageSync('character');
	}
}
import { reactive } from 'vue';
export const dzcharacter = reactive(data);